package com.healthcloud.entity;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;

public class BaseEntityTimeChange  extends BaseEntity {

//	DateTimeFormatter format = DateTimeFormatter.forPattern("yyyy-MM-dd HH:mm:ss");
	protected String createdTimeOfString; //创建时间String格式

	protected String updatedTimeOfString; //更新时间String格式
	
	public BaseEntityTimeChange(){
		
	}

	public String getCreatedTimeOfString() {
		return createdTimeOfString;
	}

	public void setCreatedTimeOfString(String createdTimeOfString) {
		this.createdTimeOfString = createdTimeOfString;
	}

	public String getUpdatedTimeOfString() {
		return updatedTimeOfString;
	}

	public void setUpdatedTimeOfString(String updatedTimeOfString) {
		this.updatedTimeOfString = updatedTimeOfString;
	}
	
	/**
	 * 将DateTime类型转换成String类型
	 * @param dateTime
	 * @return
	 */
	public String DateTimeTransformString(Date dateTime){
//		String string = formatter.format(dateTime);
		String StringTimeForm = "yyyy-MM-dd HH:mm:ss";
//		String string = dateTime.toString(StringTimeForm);
		SimpleDateFormat sdf = new SimpleDateFormat(StringTimeForm);
		String string = sdf.format(dateTime);
		System.out.println(string);
		
//		dateTime.toDateTimeString();
		return string;
	}

	/**
	 *将DateTime类型转换成String类型 可以自定义转换格式
	 * @param fommer
	 * @param dateTime
	 * @return
	 */
	public String DateTimeTransformString(String fommer,DateTime dateTime){
		return dateTime.toString(fommer);
	}

	/**
	 * 将String类型转换为DateTime
	 * @param dateTime
	 * @return
	 */
	public DateTime StringTransformDateTime(String dateTime){
		DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); 
		return DateTime.parse(dateTime, format);
	}

	/**
	 * Util转String
	 * @param format
	 * @param date
	 * @return
	 */
	public String DateChangeString(String format, Date date){
		SimpleDateFormat df=new SimpleDateFormat(format);
		return df.format(date);
	}

	/**
	 * String转化Util
	 * @param format
	 * @param dateString
	 * @return
	 */
	public Date StringFormatDate(String format,String dateString){
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		Date date=null;
		try {
			date=sdf.parse(dateString);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}

	/*
	public void setCreatedTime(DateTime createdTime) {
		this.createdTime = createdTime;
	}

	public void setCreatedTime(String createdTime) {
		this.createdTime = DateTime.parse(createdTime, format);
	}
	
	public void setUpdatedTime(DateTime updatedTime) {
		this.updatedTime = updatedTime;
	}
	
	public void setUpdatedTime(String updatedTime) {
		this.updatedTime = DateTime.parse(updatedTime, format);
	}
	 
	public DateTime getCreatedTime() {
		return createdTime;
//		return formatter.format(createdTime);
	}
	
	public DateTime getUpdatedTime() {
		return updatedTime;
	}
	*/
}
